class PaquetesController < ApplicationController
	before_filter :login_required
  # GET /paquetes
  # GET /paquetes.xml
  def index
    @paquetes = Paquete.find(:all).reverse

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @paquetes.to_xml }
    end
  end
  
  def search  	
    @paquetes = Paquete.find(:all, :conditions=>["nombre like ?", "%"+params[:key]+"%"])
    respond_to do |format|
      format.html { render :action => 'index' }
      format.xml  { render :xml => @proveedores.to_xml }
    end    
  end

  # GET /paquetes/1
  # GET /paquetes/1.xml
  def show
    @paquete = Paquete.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @paquete.to_xml }
    end
  end

  # GET /paquetes/new
  def new
    @paquete = Paquete.new
  end

  # GET /paquetes/1;edit
  def edit
    @paquete = Paquete.find(params[:id])
  end

  # POST /paquetes
  # POST /paquetes.xml
  def create
    @paquete = Paquete.new(params[:paquete])

    respond_to do |format|
      if @paquete.save
        flash[:notice] = 'Paquete was successfully created.'
        format.html { redirect_to paquete_url(@paquete) }
        format.xml  { head :created, :location => paquete_url(@paquete) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @paquete.errors.to_xml }
      end
    end
  end

  # PUT /paquetes/1
  # PUT /paquetes/1.xml
  def update
    @paquete = Paquete.find(params[:id])

    respond_to do |format|
      if @paquete.update_attributes(params[:paquete])
        flash[:notice] = 'Paquete was successfully updated.'
        format.html { redirect_to paquete_url(@paquete) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @paquete.errors.to_xml }
      end
    end
  end

  # DELETE /paquetes/1
  # DELETE /paquetes/1.xml
  def destroy
    @paquete = Paquete.find(params[:id])
    @paquete.destroy

    respond_to do |format|
      format.html { redirect_to paquetes_url }
      format.xml  { head :ok }
    end
  end
end
